package com.walter.learn.TestUtil;

import org.junit.Test;

import java.io.File;
import java.io.InputStream;

import static com.walter.learn.Util.HandleImageUtil.toWebpFile;
import static com.walter.learn.Util.HandleImageUtil.toWebpStream;

/**
 * @ProjectName: learnDemo
 * @Package: com.walter.util.Test
 * @ClassName: HandleImageUtilTest
 * @Author: DELL
 * @Description: ${description}
 * @Date: 2019/8/14 20:23
 * @Version: 1.0
 */
public class HandleImageUtilTest {

    /**
     * @Description 将url图片格式生成webp文件，返回文件
     * @Create 2019/8/15 16:04
     * @Author wangzheng
     */
    @Test
    public void testToWebpFileUrl(){
        String imgUrlPath = "E:\\imagesToWebp\\1";
        File result = toWebpFile("http://img.redocn.com/sheji/20141219/zhongguofengdaodeliyizhanbanzhijing_3744115.jpg",imgUrlPath);
    }

    /**
     * @Description 传入图片文件路径，将其转换为webp格式,默认存储在源文件路径下,返回文件
     * @Create 2019/8/15 16:06
     * @Author wangzheng
     */
    @Test
    public void testToWebpFileLocal(){
        String filePath="E:\\imagesToWebp\\xinxiang_quesheng.png";
        File file = toWebpFile(filePath);
    }

    /**
     * @Description 传入图片文件路径，将其转换为webp格式,默认存储在源文件路径下，返回InputStream
     * @Create 2019/8/15 16:10
     * @Author wangzheng
     */
    @Test
    public void testToWebpStreamLocal(){
        String filePath="E:\\imagesToWebp\\xinxiang_quesheng.png";
        InputStream inputStream = toWebpStream(filePath);
    }

    /**
     * @Description 将url图片格式生成webp文件，返回InputStream
     * @Create 2019/8/15 16:04
     * @Author wangzheng
     */
    @Test
    public void testToWebpStreamURL(){
        String imgUrlPath = "E:\\imagesToWebp\\1";
        InputStream inputStream = toWebpStream("http://img.redocn.com/sheji/20141219/zhongguofengdaodeliyizhanbanzhijing_3744115.jpg", imgUrlPath);
    }


}
